package com.retail.bbq.cola.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

import java.net.URLEncoder;
import java.util.Base64;
@Slf4j
public class Base64Util {

    public static String encode(String info) {
        log.info(info);
        if (StringUtils.isEmpty(info)) {
            return info;
        }
        try {
            byte[] decode = Base64.getEncoder().encode(URLEncoder.encode(info,"UTF-8").getBytes());
            return new String(decode).replace("0x","zero_x").replace("0X","zero_X");
        } catch (Exception e) {
            return info;
        }
    }
}
